package com.srwl.mytx.converter;

import com.alibaba.fastjson.parser.DefaultJSONParser;
import com.alibaba.fastjson.parser.deserializer.ObjectDeserializer;
import com.srwl.mytx.domain.LatLng;

import java.lang.reflect.Type;

public class AmapLocationDeserializer implements ObjectDeserializer {
    @Override
    public <T> T deserialze(DefaultJSONParser parser, Type type, Object fieldName) {

        String input = parser.getInput();
        String[] lonLat = input.split(",");
        return (T) new LatLng(Double.valueOf(lonLat[1]), Double.valueOf(lonLat[0]));

    }

    @Override
    public int getFastMatchToken() {
        return 0;
    }
}
